﻿<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Jdjf_Edit_gjls.aspx.vb" Inherits="Slxt.Jdjf_Edit_gjls"%>
<%@ Register TagPrefix="mnu" Namespace="Mysoft.Map.Application.Menus" Assembly="Mysoft.Map.Application.Components" %>
<%@ Register TagPrefix="mwc" Namespace="MySoft.WebControls" Assembly="MySoft.WebControls" %>
<HTML>
	<HEAD>
		<title>跟进历史</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR" />
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE" />
		<meta content="JavaScript" name="vs_defaultClientScript" />
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
		<link rel="stylesheet" type="text/css" href="/_grid/map_grid.css" />
		<link rel="stylesheet" type="text/css" href="/_nav/menu.css" />
		<link rel="stylesheet" type="text/css" href="/_forms/styles/form.css" />
		<link rel="stylesheet" type="text/css" href="/_controls/find/find.css" />
		<link rel="stylesheet" type="text/css" href="/_common/styles/global.css" />
		<script language="javascript" src="/_common/scripts/global.js"></script>
		<script language="javascript" src="/_controls/settings.aspx"></script>
		<script language="javascript" src="/_controls/util/util.js"></script>
		<script language="javascript" src="/_controls/datetime/date.js"></script>
		<script language="javascript" src="/_controls/number/number.js"></script>
		<script language="javascript" src="/_grid/rep_grid.js"></script>
		<script language="javascript" src="/_nav/menu.js"></script>
		<script type="text/javascript" src="/PubProject/js/Public.js"></script>
		<script language="javascript" src="/Slxt/js/Public.js"></script>

        <style>
                td.gridBorder1	/* 用于repeater中的TD加上底线！*/
                {
	                border-top: 1px solid #FFFFFF;
	                border-bottom: 1px solid #DDDDDD;
	                padding-top:4px;
	                padding-bottom:4px;
                }
                table.gridBar1
                {
	                width: 100%;
	                border: 1px solid #DBDAC9;
	                border-bottom: 1px solid #C5C1B1;
	                background-color: #E9E7D7;
	                table-layout: fixed;
                }

                td.gridBar1		/*	新增：设置grid的头	*/
                {
	                background-color:#E9E7D7;
	                border-top:1px solid #DBDAC9;
	                border-bottom:1px solid #C5C1B1;
                }

        </style>
		<script language="javascript">
		    function window.onload() {
		        importXmlToGrid();
		        initRepeater(gridBar1);
		        if (parent.__mode.value == "3" || parent.appForm.Status.value == "丢失")
		        {
		            deDisplay("m2,m3");
		        }
		    };

		    //初始化
		    function initRepeater(tbl) {
		        // 初始化Repeater
		        initGrid(tbl);
		        tbl._iNumSelected = 2;
		        // 自适应高度
		        //ChangeGridHeight(MainTable);
		    }


		    //将跟进记录动态加入列表中
		    function importXmlToGrid() {
		        var o = document.all("gridBar1");
		        for (var i = 1; i < o.rows.length; i++) {
		            if (o.rows[i].selected) {
		                o.deleteRow(i);
		            }
		        }

		        //获取记录数据xml
		        var strDataXml = document.getElementById("txtGjjlInfo").value;
		        if (strDataXml != "" && strDataXml != undefined) {
		            var xmlDom = new ActiveXObject("Microsoft.XMLDOM");
		            try {
		                xmlDom.loadXML(strDataXml);
		            }
		            catch (e) {
		                alert("缓存的折扣列表xml格式错误，请与管理员联系！");
		                return;
		            }

		            var strGjjl, strOppGUID;
		            
		            var iGjNum = 0;
		            var xmlNodes = xmlDom.documentElement.selectNodes("/dataxml/row")

		            for (var i = xmlNodes.length-1; i >= 0  ; i--) {
		                var arrGjjl = [];
		                //获取上一条记录的机会GUID，用于多条机会时的数据处理
		                if (i == xmlNodes.length-1) {
		                    strOppGUID = xmlNodes[i].attributes.getNamedItem("oid").text;
		                }
		                else {
		                    strOppGUID = xmlNodes[i + 1].attributes.getNamedItem("oid").text;
		                }

		                //收集跟进记录数据
		                arrGjjl.push(xmlNodes[i].attributes.getNamedItem("oid").text);
		                arrGjjl.push(xmlNodes[i].attributes.getNamedItem("entity").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("BUName").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("ProjName").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("Remark").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("GjDate").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("Status").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("Gfyx").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("Gjfs").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("GjContent").text);
		                arrGjjl.push(xmlNodes[i].selectSingleNode("UserName").text);

		                //由于可能取出多条机会，所以需要判断跟进记录是否属于同一机会，如果不属于同一机会，需从新定义跟进次数。
		                if (strOppGUID != xmlNodes[i].attributes.getNamedItem("oid").text) {
		                    iGjNum = 1;
		                }
		                else {
		                    iGjNum = iGjNum + 1;
		                }
		                insertRow(arrGjjl.join("|"), strOppGUID, iGjNum);
		            }
		        }
		    };
		    //向Rep中插入数据
		    function insertRow(strGjjl, strOppGUID, iGjNum) {
		        var arrValue = strGjjl.split("|");
		        var strRemark;
		        var o = document.all("gridBar1");
	            var trHTML = o.rows[o.rows.length-1].outerHTML;
            	
	            var objAddRow = o.insertRow(o.rows.length);
	            //控制备注显示长度
	            if (arrValue[4].lenght > 43) {
	                strRemark = arrValue[4].substring(0, 43) + "....";
	            }
	            //设置行属性
               objAddRow.setAttribute("oid", arrValue[0]);
               objAddRow.setAttribute("entity", arrValue[1]);
               
	            //序号
	            objAddCell = objAddRow.insertCell(0);
	            objAddCell.align = "center";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd",o.rows.length-1);
	            objAddCell.colSpan = "2";
	            //objAddCell.height = "100%";
	            objAddCell.style.wordWrap = "break-word";

	            //BUName
	            objAddCell = objAddRow.insertCell(1);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[2]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //ProjName
	            objAddCell = objAddRow.insertCell(2);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[3]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //Remark
	            objAddCell = objAddRow.insertCell(3);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            if (arrValue[4] == "") {
	                objAddCell.insertAdjacentHTML("BeforeEnd", "&nbsp;");
	            }
	            else {
	                objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[4]);
	            }
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";
	            objAddCell.title = arrValue[4];
	            //objAddCell.style.padding="5";
	            
	            //GjStatus
	            objAddCell = objAddRow.insertCell(4);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", "第" + iGjNum + "次跟进");
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //GjDate
	            objAddCell = objAddRow.insertCell(5);
	            objAddCell.align = "center";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[5]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //Status
	            objAddCell = objAddRow.insertCell(6);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[6]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //Gfyx
	            objAddCell = objAddRow.insertCell(7);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[7]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //Gjfs
	            objAddCell = objAddRow.insertCell(8);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[8]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //GjContent
	            objAddCell = objAddRow.insertCell(9);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            if (arrValue[9] == "") {
	                objAddCell.insertAdjacentHTML("BeforeEnd", "&nbsp;");
	            }
	            else {
	                objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[9]);
	            }
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";

	            //UserName
	            objAddCell = objAddRow.insertCell(10);
	            objAddCell.align = "left";
	            objAddCell.className = "gridBorder1";
	            objAddCell.insertAdjacentHTML("BeforeEnd", arrValue[10]);
	            objAddCell.colSpan = "2";
	            objAddCell.style.wordWrap = "break-word";
	        }

	        //打印功能
	        function doPrint() {
	            var title = "跟进历史";

	            var oForm = window.document.createElement("<form name='gridExportPrint' method='post' style='display:none'>");
	            window.document.body.insertBefore(oForm);
	            oForm.action = "/slxt/pub/PrintRepeater.aspx";
	            oForm.target = "exportFrame";

	            var oInput = window.document.createElement("<input type='hidden'>");
	            oInput.name = "tableHtml";
	            oInput.value = document.getElementById("gridBar1").outerHTML;
	            oForm.appendChild(oInput);

	            oForm.submit();
	        }

	        //导出功能
	        function doToExcel() {
	            ExportExcel("gridBar1");
	        }

	        //导出excel
	        //参数:
	        //   strQtobj 显示这个对象里面的内容
	        function ExportExcel(strQtobj) {
	            try {
	                var obj;
	                if (strQtobj != undefined && strQtobj != "") {
	                    obj = document.getElementById(strQtobj);
	                }
	                else {
	                    obj = document.getElementById("objTable");
	                }

	                var regEx, regEx1;
	                var strHTML;
	                var regHTML;

	                var divExcel = document.createElement("div");
	                //过滤掉其中的Image图片
	                regEx = /<td.*<img.*<\/td>/gi;
	                //过滤掉特俗字符
	                //匹配超链接和事件
	                regEx1 = /on[^=]+=\s*([""']?)[^'""\s<>]+\1/gi;
	                divExcel.innerHTML = obj.outerHTML.replace(regEx, "").replace(/<a.*?>/ig, "").replace(/<\/a>/ig, "").replace(regEx, "");

	                obj = divExcel.children(0);
	                obj.removeChild(obj.firstChild);
	                //设置导出TABLE的样式
	                obj.style.fontSize = "10pt";
	                obj.style.tableLayout = "fixed";
	                // 遍历行设置样式、重置colspan、格式化超链接内容
	                var rowCount = obj.rows.length; //所有行数
	                var colCount, i, j;
	                // 为每列第一个单元格命名
	                for (i = 0; i < rowCount; i++) {
	                    // 设置表头和数据行的样式
	                    if (i == 0 || i == 1) {
	                        obj.rows[i].style.height = "22px";
	                        obj.rows[i].style.backgroundColor = "#FFFFFF";

	                    } else {
	                        obj.rows[i].style.backgroundColor = "#FFFFFF";
	                    }
	                    //获取所有列数，由于去掉了表头中的Img，colSpan需要处理
	                    colCount = obj.rows[i].cells.length;
	                    for (j = 0; j < colCount; j++) {
	                        if (obj.rows[i].cells[j].colSpan == 10) {
	                            obj.rows[i].cells[j].firstChild.style.fontSize = "10pt";
	                        }
	                        obj.rows[i].cells[j].colSpan = (obj.rows[i].cells[j].colSpan + 1) / 2;
	                    }
	                }
	                regHTML = obj.outerHTML;

	                strHTML = '<META http-equiv="Content-Type" content="text/html;charset=gb2312">';

	                strHTML += regHTML;

	                MyZipLib.SaveToFile(strHTML);


	            }
	            catch (e) { }

	        }
		</script>
	</HEAD>
	<body MS_POSITIONING="GridLayout" >
		<form id="Form1" runat="server">
		    <asp:textbox id="txtGjjlInfo" style="DISPLAY: none" runat="server" />
	        <asp:textbox id="txtGfyxInfo" style="DISPLAY: none" runat="server" />
	        <asp:textbox id="txtKhztInfo" style="DISPLAY: none" runat="server" />
	        <table style="FONT-SIZE: 9pt" height="100%" cellSpacing="0" cellPadding="0" width="100%" bgcolor="white">
	            <tr><td style=" height:30px;font-weight:bold">跟进历史记录</td></tr>
			    <tr>
			        <td height="75px">
			            <table style="FONT-SIZE: 9pt" height="75px" cellSpacing="0" cellPadding="0" width="100%" >
                            <tr>
				                <td width="80px">意向创建时间</td>
				                <td width="200px">
                                    <asp:Label ID="lblCreatedOn" runat="server" Text=""></asp:Label></td>
				                <td width="60px">创建人</td>
				                <td width="200px">
                                    <asp:Label ID="lblCreatedBy" runat="server" Text=""></asp:Label></td>
				                <td width="60px">客户来源</td>
				                <td width="200px">
                                    <asp:Label ID="lblOppSource" runat="server" Text=""></asp:Label></td>
                            </tr>
                            <tr>
				                <td width="80px">意向分配时间</td>
				                <td width="200px">
                                    <asp:Label ID="lblFpTime" runat="server" Text=""></asp:Label></td>
				                <td width="60px">分配人</td>
				                <td width="200px">
                                    <asp:Label ID="lblSPUserName" runat="server" Text=""></asp:Label></td>
				                <td width="60px">置业顾问</td>
				                <td width="200px">
                                    <asp:Label ID="lblZYUserName" runat="server" Text=""></asp:Label></td>
                            </tr>
                            <tr>
				                <td width="80px">到访现场次数</td>
				                <td width="200px">
                                    <asp:Label ID="lblDfNum" runat="server" Text=""></asp:Label></td>
				                <td width="60px">分配次数</td>
				                <td width="200px">
                                    <asp:Label ID="lblFpNum" runat="server" Text=""></asp:Label></td>
				                <td width="60px"></td>
				                <td></td>
                            </tr>
                        </table>
                    </td>
                </tr>
			    <tr height="1">
				    <td>
					    <mnu:AppGridMenu id="appGridMenu" runat="server" />
				    </td>
			    </tr>
			    <tr>
				    <td valign="top">
					    <mwc:repeater id="myRepeater" runat="server" SortSignASC='<img src="/_imgs/ico_arrow_u.gif">' SortSignDESC='<img src="/_imgs/ico_arrow_d.gif">' EnablePager="false">
				            <HEADERTEMPLATE>
					            <TABLE height="100%" id="MainTable" cellSpacing="0" cellPadding="0" width="100%" style="table-layout:fixed;">
						            <TBODY>
							            <TR vAlign="top" height="22">
								            <TD>
									            <DIV style="OVERFLOW: auto;  WIDTH: 100%;  HEIGHT: 100%">
										            <TABLE id="gridBar1" onclick="handleClick();" cellSpacing="0" cellPadding="0" border="0" gridID="myRepeater" width="100%" style="table-layout:fixed; CURSOR: hand;">
											            <COLGROUP id="gridBarCols">
												            <col width="40">
									                        <col width="2">
									                        <col width="80">
									                        <col width="2">
									                        <col width="80">
									                        <col width="2">
									                        <col width="150">
									                        <col width="2">
									                        <col width="70">
									                        <col width="2">
									                        <col width="75">
									                        <col width="2">
									                        <col width="75">
									                        <col width="2">
									                        <col width="75">
									                        <col width="2">
									                        <col width="75">
									                        <col width="2">
									                        <col width="200">
									                        <col width="2">
									                        <col width="70">
									                        <col width="2">
											            </COLGROUP>
											            <TBODY>
												            <TR id="trHeader" style="CURSOR: hand" align="center" height="22">
													            <td align="center" class="gridBar"><nobr>序号</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>公司</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>项目名称</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>备注</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>联系状态</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>联系日期</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>客户状态</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>购房意向</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>跟进方式</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>跟进内容</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
										                        <td class="gridBar"><nobr>跟进人</nobr></td>
										                        <td class="gridBar"><img src="/_imgs/bar_line.gif"></td>
												            </TR>
															
				            </HEADERTEMPLATE>
				                <ITEMTEMPLATE>							
					                <tr oid='<%# DataBinder.Eval(Container.DataItem, "OppGUID") %>' >
                                        <td align="center" colspan="2"><%# Container.ItemIndex+1 %></td>
                                        <td colspan="2"  class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "BUName")%></span></td>
                                        <td colspan="2"  class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "ProjName")%></span></td>
                                        <td colspan="2"  class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "Remark")%></span></td>
                                        <td colspan="2"  class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "GjStatus")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "GjDate")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "Status")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "Gfyx")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "Gjfs")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "GjContent")%></span></td>
                                        <td colspan="2" class="gridBorder" style="height:100%; word-wrap:break-word"><span><%#DataBinder.Eval(Container.DataItem, "UserName")%></span></td>
                                    </tr>
				                </ITEMTEMPLATE>
				            <FOOTERTEMPLATE>
				            </TBODY>
			            </table>
			            </DIV></TD></TR></TBODY></TABLE></FOOTERTEMPLATE> 
			            </mwc:repeater>
				    </td>
			    </tr>
		    </table>
		</form>
		
		<OBJECT id="MyZipLib"  CLASSID="CLSID:23676334-DBF4-4493-8F23-B15375FD923E" CODEBASE="/ActiveX/PBHelper/PBHelper.CAB#version=2,2,0,0" VIEWASTEXT>
			<PARAM NAME="_ExtentX" VALUE="159">
			<PARAM NAME="_ExtentY" VALUE="159">
	    </OBJECT>
	</body>
</HTML>
